home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Lib / DTS.Lib.headers / StringUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  3.1 KB  |  98 lines  |  [TEXT/MPS ]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Header file for collection of String Utilities for DTS Sample code
  5. **
  6. **    Copyright © 1988-1992 Apple Computer, Inc.
  7. **    All rights reserved.
  8. */
  9.  
  10.  
  11. #ifndef __STRINGUTILS__
  12. #define __STRINGUTILS__
  13.  
  14. #ifdef applec
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19.  
  20. #endif
  21.  
  22.  
  23. /* These are duplicates of c-library functions.  The reason for duplicating them
  24. ** is so that the StringUtils code can be small and linked in with other code that
  25. ** stays resident at all times.  It is possible that when you call code to do
  26. ** something as seemingly innocent as getting the length of a string, memory can
  27. ** move.  This is because the code you are calling isn't necessarily in memory.
  28. ** If the code segment that contains the code you are calling isn't in ram, then
  29. ** it has to be loaded.  Loading the code may cause memory compaction, and therefore
  30. ** memory can move.  The pointer to the string is already pushed on the stack prior
  31. ** to the call, so if you passed a pointer into an unlocked handle, after calling
  32. ** the code, that handle may have moved, and therefore the pointer is invalid.
  33. **
  34. ** To prevent the above problem, alternate names were used for these common library
  35. ** functions.  Link this code into the same segment that holds main(), and you will
  36. ** be guaranteed that they will be in memory whenever you call them. */
  37.  
  38. short    clen(char *cptr);
  39. char    *ccat(char *s1, char *s2);
  40. char    *ccpy(char *s1, char *s2);
  41. void    pcat(StringPtr d, StringPtr s);
  42. void    pcpy(StringPtr d, StringPtr s);
  43.  
  44. void    c2p(char *cptr);
  45. void    p2c(StringPtr cptr);
  46.  
  47.  
  48. /*****************************************************************************/
  49.  
  50. /* These are useful, relatively small routines for string manipulation.  As with the
  51. ** above calls, link them into the code segment that holds main().
  52. **
  53. ** With the below functions, you will have most of the functionality of sprintf
  54. ** using shorts and longs.  It will take more calls, but only what you call is linked
  55. ** in. */
  56.  
  57.  
  58. /**/
  59.  
  60. void    ccatchr(char *cptr, char c, short count);
  61. void    ccatdec(char *cptr, long v);
  62. void    ccathex(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  63. void    ccatnum(char *cptr, long v, short base);
  64.  
  65. void    ccpychr(char *cptr, char c, short count);
  66. void    ccpydec(char *cptr, long v);
  67. void    ccpyhex(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  68. void    ccpynum(char *cptr, long v, short base);
  69.  
  70. long    c2dec(char *cptr, short *charsUsed);
  71. long    c2hex(char *cptr, short *charsUsed);
  72. long    c2num(char *cptr, short base, short *charsUsed);
  73.  
  74. /**/
  75.  
  76. void    pcatchr(StringPtr pptr, char c, short count);
  77. void    pcatdec(StringPtr pptr, long v);
  78. void    pcathex(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  79. long    pcatnum(StringPtr pptr, long v, short base);
  80.  
  81. void    pcpychr(StringPtr pptr, char c, short count);
  82. void    pcpydec(StringPtr pptr, long v);
  83. void    pcpyhex(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  84. void    pcpynum(StringPtr pptr, long v, short base);
  85.  
  86. long    p2dec(StringPtr pptr, short *charsUsed);
  87. long    p2hex(StringPtr pptr, short *charsUsed);
  88. long    p2num(StringPtr pptr, short base, short *charsUsed);
  89.  
  90. /**/
  91.  
  92. short    GetHexByte(char *cptr);
  93.  
  94. #endif __STRINGUTILS__
  95.  
  96.  
  97.  
  98.